package org.dxy.infrastructure.persistent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dxy.infrastructure.entity.query.BomViewEntity;
import org.dxy.infrastructure.persistent.mapper.BomViewMapper;
import org.dxy.infrastructure.persistent.service.BomViewService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * BOM查询服务实现
 */
@Service
public class BomViewServiceImpl extends ServiceImpl<BomViewMapper, BomViewEntity> implements BomViewService {
    
    @Override
    public BomViewEntity getByProductId(Long productId) {
        LambdaQueryWrapper<BomViewEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BomViewEntity::getProductId, productId);
        return getOne(queryWrapper);
    }
    
    @Override
    public List<BomViewEntity> listByProductIds(List<Long> productIds) {
        if (productIds == null || productIds.isEmpty()) {
            return List.of();
        }
        LambdaQueryWrapper<BomViewEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(BomViewEntity::getProductId, productIds);
        return list(queryWrapper);
    }
}